package com.study.talk.netty.handler;

import android.util.Log;

import com.study.common.event.Constants;
import com.study.common.EventBusUtil;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class ResponseHandler<T> extends SimpleChannelInboundHandler<T> {
    private static final String TAG = "ResponseHandler";

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, T msg) throws Exception {
        Log.i(TAG, "channelRead0: ");
        EventBusUtil.sendEvent(msg);
        if (!ctx.channel().isActive()){
            EventBusUtil.sendEvent(Constants.EVENT_NETTY_DISCONNECT);
        }
    }
}
